// 退货单处理

import request from '@/utils/request'

const api = {
  orderList: '/reject/rejectSaleList',
  rejectSaleAdd: '/reject/saleAdd',
  detail: '/reject/rejectSaleDetail'
}

const Map = {
  'descend': 'desc',
  'ascend': 'asc'
}

// 退货单列表
export function orderList (parameter) {
  return request({
    url: api.orderList,
    method: 'get',
    params: {
      order: Map[parameter.order] || 'asc',
      page: parameter.page || 1,
      pageSize: parameter.pageSize || 10,
      code: parameter.code,
      salesPerson: parameter.salesPerson,
      status: parameter.status
    }
  })
}

// 增加退货单
export function rejectSaleAdd (parameter) {
  return request({
    url: api.rejectSaleAdd,
    method: 'post',
    data: {
      code: parameter.code,
      rejectTime: parameter.rejectTime,
      salesPerson: parameter.salesPerson,
      auditor: parameter.auditor,
      rejectRemark: parameter.rejectRemark
    }
  })
}

// detail
export function detail (parameter) {
  return request({
    method: 'get',
    url: api.detail,
    params: {
      code: parameter.code
    }
  })
}
